package com.lwj.designpattern.create.factory;

import com.lwj.designpattern.create.factory.entity.BlackCar;
import com.lwj.designpattern.create.factory.entity.Car;
import com.lwj.designpattern.create.factory.entity.YellowCar;
import org.springframework.util.ObjectUtils;

import java.util.HashMap;
import java.util.Map;

/**
 *简单工厂模式
 * @author wujilee
 * @date 2022/11/15
 */
public class SimpleFactory {
    private Map<String, Car> mapCar = new HashMap();

    public SimpleFactory(Map<String, Car> mapCar) {
        mapCar.put("yellow",new YellowCar());
        mapCar.put("black",new BlackCar());
    }
    public  Car createCar(String color){
        return mapCar.get(color);

    }
}
